package com.opennews.openplatform.controller;

import com.opennews.openplatform.service.OrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RequiredArgsConstructor
@RestController
@RequestMapping("/orders")
public class OrderController {
    private final OrderService orderService;

    @GetMapping
    public ResponseEntity<List<Map<String, Object>>> list() {
        List<Map<String, Object>> list = orderService.queryList();
        return ResponseEntity.ok(list);
    }

    @PostMapping
    public ResponseEntity placeOrder() {
        orderService.placeOrder();
        return ResponseEntity.ok().build();
    }
}